package com.heima.common.tess4j;

import lombok.Data;
import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Data
@Configuration
@Component
@ConfigurationProperties(prefix = "tess4j")
public class Tess4jConfiguration {

    private String datapath;
    private String language;

    @Bean
    public ITesseract createTesseract(){
        //创建Tesseract对象
        ITesseract tesseract = new Tesseract();

        //设置中文语言包
        tesseract.setDatapath(datapath);//语言包文件所在目录
        tesseract.setLanguage(language);//语言包文件名、语言名称

        return tesseract;
    }
}
